package com.example.mybatistest.config;

import com.example.mybatistest.interceptor.H_SqlFormatInterceptor;
import com.example.mybatistest.interceptor.H_SqlHumpInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisConfiguration {

    @Bean
    public String  myBatisInterceptor(SqlSessionFactory sqlSessionFactory) {

        // 打印完整SQL（带参数）
        sqlSessionFactory.getConfiguration().addInterceptor(new H_SqlFormatInterceptor());
        // 下划线转驼峰
        sqlSessionFactory.getConfiguration().addInterceptor(new H_SqlHumpInterceptor());
        return "interceptor";
    }
}
